package com.lysh.aliHttp.model;

import java.util.HashMap;
import java.util.Map;

/**
 * @author liyishan
 * @date 2023/5/5 09:53
 * @apiNote
 */

public class Callback {
    private String callbackUrl;
    private String callbackHost;
    private String callbackBody;
    private CalbackBodyType calbackBodyType;
    private Map<String, String> callbackVar = new HashMap();

    public Callback() {
    }

    public String getCallbackUrl() {
        return this.callbackUrl;
    }

    public void setCallbackUrl(String callbackUrl) {
        this.callbackUrl = callbackUrl;
    }

    public String getCallbackHost() {
        return this.callbackHost;
    }

    public void setCallbackHost(String callbackHost) {
        this.callbackHost = callbackHost;
    }

    public String getCallbackBody() {
        return this.callbackBody;
    }

    public void setCallbackBody(String callbackBody) {
        this.callbackBody = callbackBody;
    }

    public CalbackBodyType getCalbackBodyType() {
        return this.calbackBodyType;
    }

    public void setCalbackBodyType(CalbackBodyType calbackBodyType) {
        this.calbackBodyType = calbackBodyType;
    }

    public Map<String, String> getCallbackVar() {
        return this.callbackVar;
    }

    public void setCallbackVar(Map<String, String> callbackVar) {
        this.callbackVar.clear();
        if (callbackVar != null && !callbackVar.isEmpty()) {
            this.callbackVar.putAll(callbackVar);
        }

    }

    public void addCallbackVar(String key, String value) {
        this.callbackVar.put(key, value);
    }

    public boolean hasCallbackVar() {
        return this.callbackVar != null && this.callbackVar.size() > 0;
    }

    public static enum CalbackBodyType {
        URL(1),
        JSON(2);

        private int nCode;

        private CalbackBodyType(int nCode) {
            this.nCode = nCode;
        }

        public String toString() {
            return String.valueOf(this.nCode);
        }
    }
}
